package com.bleeth.fx.component;

import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.StrUtil;
import javafx.scene.control.Button;
import javafx.scene.layout.Region;
import lombok.Builder;


/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@Builder
public class MDescriptions {

    private static final String TAG = "el-button";

    private String type;

    private boolean plain;

    private boolean round;

    private String icon;

    private boolean disabled;

    private boolean circle;

    private boolean loading;

    private String size;

    private String text;

    private Button button;

    public Button make() {
        button = new Button();
        button.getStylesheets().add("/css/MButton.css");
        style(button);
        button.setText(text);
        return button;
    }


    public void style(Region region) {
        StrBuilder style = new StrBuilder(TAG);
        if (StrUtil.isNotEmpty(type)) {
            style.append("--").append(type);
        }
        if (plain) {
            style.append("_").append("is-plain");
        }
        if (disabled) {
            style.append("_").append("is-disabled");
        }
        if (round) {
            style.append("_").append("is-round");
        }
        region.getStyleClass().clear();
        region.getStyleClass().add(TAG);
        region.getStyleClass().add(style.toString());
    }

}
